<!--
 * @Description: 项目策划任务表
 * @Author: wind-lc
 * @version: 1.0
 * @Date: 2022-02-15 14:43:34
 * @LastEditTime: 2022-02-15 14:44:56
 * @FilePath: \cscec-pms-admin\src\views\project\projectManagementPlanning\projectPlanningTaskList\index.vue
-->
<template>
  <div>
    <base-breadcrumb :title="$route.meta.title">
      <a-row :gutter="10">
        <a-col :span="24">
          <!-- 搜索 -->
          <searchData :search-data="searchOption" @search="search" />
          <PlanningTaskList :searchQuery="searchQuery" ref="PlanningTaskList"></PlanningTaskList>
        </a-col>
      </a-row>
    </base-breadcrumb>
  </div>
</template>
<script>
import { searchOption } from './config'
import PlanningTaskList from './components/PlanningTaskList'
import { list } from '@/api/projectManagementPlanning/projectManagementPlanningSchedule'
import Vue from 'vue'
export default {
  name: 'ProjectPlanningTaskList',
  components: { PlanningTaskList },
  data() {
    return {
      searchOption: [...searchOption],
      searchQuery: {}
    }
  },
  mounted() {
    // const {
    //   currentPost: { id, tagCode, orgId }
    // } = Vue.getAcloudProvider().getUserInfo()
    // if (tagCode === 'CO') {
    //   this.searchOption[0].getAll = true
    //   this.searchOption[0].autoSelected = false
    // }
    // if (tagCode === 'BC') {
    //   this.searchOption[0].getAll = false
    //   this.searchOption[0].autoSelected = true
    //   this.searchOption[0].value = orgId
    //   this.searchOption[1].onlyCurrentPd = true
    //   this.getProjectName(id)
    // }
    const query = {}
    // if (this.searchOption[0].value) {
    //   query.branchId = this.searchOption[0].value
    // }
    // if (this.searchOption[1].value) {
    //   query.projectId = this.searchOption[1].value 
    // }
    this.search(query)
  },
  methods: {
    /**
     * @description: 获取当前登录人项目名称
     * @param {void}
     * @return {void}
     */
    getProjectName(id) {
      return new Promise((resolve, reject) => {
        list.downProject({ deptOrgIds: [id] }).then(({ data }) => {
          if (data.length == 1) {
            this.searchOption[1].value = data[0].projectId
            this.searchOption[1].autoSelected = true
          }
          resolve()
        })
      })
    },
    search(val) {
      Object.keys(this.searchQuery).map((key) => {
        this.$set(this.searchQuery, key, '')
      })
      Object.keys(val).map((key) => {
        this.$set(this.searchQuery, key, val[key])
      })
      this.$refs.PlanningTaskList.$refs.table.refresh(true)
    }
  }
}
</script>
<style lang="less" scoped>
</style>
